﻿<controls:MetroWindow  x:Class="YAWD.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:yawDuc="clr-namespace:YAWD.UserControls"
        xmlns:tb="http://www.hardcodet.net/taskbar"
        xmlns:command="clr-namespace:YAWD.Utils" 
        xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        StateChanged="MainPage_StateChanged" Closing="MainPage_Closing"
        Title="Yawd"
        WindowStartupLocation="CenterScreen" WindowState="Minimized" ShowInTaskbar="False" 
        SourceInitialized="MainPage_SourceInitialized" SaveWindowPosition="True" ShowIconOnTitleBar="False" TitleCaps="True"
        Height="550" Width="Auto" x:Name="MainPage">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedTabControl.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <!--Donate Button-->
            <Style x:Key="DonateButton" TargetType="{x:Type Button}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Button}">
                            <Border Name="Bd"  
                            Background="Transparent"  
                            BorderBrush="{TemplateBinding BorderBrush}"  
                            BorderThickness="0"  
                            Padding="{TemplateBinding Padding}"  
                            SnapsToDevicePixels="true">
                                <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"  
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"  
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="true">
                                    <Setter TargetName="Bd" Property="BorderBrush" Value="Transparent"/>
                                    <Setter TargetName="Bd" Property="Background"  Value="Transparent"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="Height" Value="30"/>
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter Property="BorderBrush" Value="{DynamicResource MouseOverColor}"/>
                    </Trigger>
                </Style.Triggers>
            </Style>
            <Style x:Key="CheckBoxListStyle" TargetType="ListBox">
                <Style.Resources>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ListBoxItem">
                                    <Grid Margin="2">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                                        </Grid.ColumnDefinitions>
                                        <CheckBox  Grid.Column="0" IsChecked="{Binding IsSelected,
                                                          RelativeSource={RelativeSource TemplatedParent},
                                                          Mode=TwoWay}" VerticalAlignment="Center">
                                        </CheckBox>
                                        <ContentPresenter Grid.Column="1" Margin="20,0,0,0"/>
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Style.Resources>
                <Setter Property="ItemsPanel">
                    <Setter.Value>
                        <ItemsPanelTemplate>
                            <WrapPanel Orientation="Vertical"  />
                        </ItemsPanelTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="BorderThickness" Value="0" />
                <Setter Property="Background" Value="White" />
            </Style>
        </ResourceDictionary>
    </Window.Resources>
    <Window.CommandBindings>
        <CommandBinding Command="command:Commands.OpenApp"  Executed="OpenApp" />
    </Window.CommandBindings>
    <controls:MetroWindow.WindowCommands>
        <controls:WindowCommands>
            <Button ToolTip="Donate" Click="cmdDonate_Click" Height="30"
               Style="{StaticResource DonateButton}" HorizontalAlignment="Center" VerticalAlignment="Center">
                <Image Source="/YAWD;component/Images/Donate.png" />
            </Button>
        </controls:WindowCommands>
    </controls:MetroWindow.WindowCommands>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>

        <tb:TaskbarIcon IconSource="/YAWD;component/Images/promotion.ico" DoubleClickCommand="command:Commands.OpenApp">
            <tb:TaskbarIcon.TrayToolTip>
                <Border Background="White" BorderBrush="#FF41B1E1" BorderThickness="2" CornerRadius="4" Width="160" Height="35">
                    <TextBlock Text="Double click to open&#10;Right click for options" TextWrapping="Wrap" Foreground="Black"
                               HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Border>
            </tb:TaskbarIcon.TrayToolTip>
            <tb:TaskbarIcon.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Open" Click="ctxOpenApp_Click" />
                    <MenuItem Header="Change Wallpaper" Click="ctxChangeWallpaper_Click" />
                    <MenuItem Header="Exclude Current Wallpaper" Click="ctxExcludeCurrent_Click" />
                    <MenuItem Header="Delete Current Wallpaper" Click="ctxDeleteCurrent_Click"/>
                    <MenuItem Header="Show Current Wallpaper" Click="ctxShowCurrent_Click" />
                    <MenuItem Header="Download Wallpaper" Click="ctxDownload_Click" />
                    <MenuItem Header="Close" Click="ctxClose_Click" />
                </ContextMenu>
            </tb:TaskbarIcon.ContextMenu>
        </tb:TaskbarIcon>
        <controls:MetroContentControl>
            <Grid>
                <TabControl>
                    <TabItem Header="WallPaper">

                        <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" >
                            <StackPanel Name="mainStack">
                                <yawDuc:UcProvider x:Name="Bing" GetAll="True" IsExpanded="True"/>
                                <yawDuc:UcProvider x:Name="GoodFon" GetAll="False" IsExpanded="False"/>
                                <yawDuc:UcProvider x:Name="InterfaceLIFT" GetAll="True" IsExpanded="False"/>
                                <yawDuc:UcProvider x:Name="Randomizer" GetAll="True" IsExpanded="False"/>
                                <yawDuc:UcProvider x:Name="reWalls" GetAll="True" IsExpanded="False"/>
                                <yawDuc:UcProvider x:Name="SkinsBe" GetAll="False" IsExpanded="False"/>
                                <yawDuc:UcProvider x:Name="wallBase" GetAll="True" IsExpanded="False"/>
                            </StackPanel>
                        </ScrollViewer>
                    </TabItem>
                    <TabItem Header="Options">
                        <ScrollViewer VerticalScrollBarVisibility="Visible">
                            <StackPanel Orientation="Vertical" CanVerticallyScroll="True">
                                <GroupBox Margin="5" Header="Included Folder Path : ">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="150"/>
                                            <RowDefinition Height="35"/>
                                        </Grid.RowDefinitions>
                                        <ListBox Name="lstResults" Grid.Row="0" Style="{StaticResource CheckBoxListStyle}" 
                                                 ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                             Margin="5" SelectionMode="Multiple" ItemsSource="{Binding}"/>
                                        <StackPanel Grid.Row="1" VerticalAlignment="Center" Orientation="Horizontal">
                                            <Button Click="Add_Click" Content="Add" Margin="5" HorizontalAlignment="Left" Width="80" Height="24"/>
                                            <Button Click="Remove_Click"  Content="Remove" Margin="5" HorizontalAlignment="Left" Width="80" Height="24"/>
                                        </StackPanel>
                                    </Grid>
                                </GroupBox>
                                <GroupBox Margin="5" Header="Select Resolutionfor : Ewallpapers, InterfaceLIFT, reWalls, SkinBe, wallBase.">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="35"/>
                                        </Grid.RowDefinitions>
                                        <WrapPanel Name="wrpResolutions"  VerticalAlignment="Center" ItemHeight="30" ItemWidth="100" Orientation="Horizontal"  Grid.Row="0"/>
                                        <Button Click="ApplyRes_Click" Content="Apply" Margin="5" HorizontalAlignment="Left" Width="80" Height="24" Grid.Row="1"/>
                                    </Grid>
                                </GroupBox>
                                <GroupBox Header="Check sites you want to download images" Margin="5">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="40"/>
                                        </Grid.RowDefinitions>
                                        <StackPanel Orientation="Horizontal" Grid.Row="0">
                                            <CheckBox Name="chkBing" Margin="3,3,0,0" IsThreeState="False" VerticalAlignment="Center"/>
                                            <TextBlock Text="Bing" Margin="0,3,10,3"  VerticalAlignment="Center"/>

                                            <CheckBox Name="chkGoodFon" Margin="3,3,0,0" IsThreeState="False" VerticalAlignment="Center"/>
                                            <TextBlock Text="GoodFon" Margin="0,3,10,3"  VerticalAlignment="Center"/>

                                            <CheckBox Name="chkInterfaceLIFT" Margin="3,3,0,0" IsThreeState="False" VerticalAlignment="Center"/>
                                            <TextBlock Text="InterfaceLIFT" Margin="0,3,10,3" VerticalAlignment="Center"/>

                                            <CheckBox Name="chkRandomizer" Margin="3,3,0,0" IsThreeState="False"  VerticalAlignment="Center"/>
                                            <TextBlock Text="Randomizer" Margin="0,3,10,3" VerticalAlignment="Center"/>

                                            <CheckBox Name="chkreWalls" Margin="3,3,0,0" IsThreeState="False" VerticalAlignment="Center"/>
                                            <TextBlock Text="reWalls" Margin="0,3,10,3"  VerticalAlignment="Center"/>

                                            <CheckBox Name="chkSkinsBe" Margin="3,3,0,0" IsThreeState="False" VerticalAlignment="Center"/>
                                            <TextBlock Text="SkinsBe" Margin="0,3,10,3"  VerticalAlignment="Center"/>

                                            <CheckBox Name="chkwallBase" Margin="3,3,0,0" IsThreeState="False" VerticalAlignment="Center"/>
                                            <TextBlock Text="wallBase" Margin="0,3,10,3" VerticalAlignment="Center"/>
                                        </StackPanel>
                                        <Button Click="ApplySites_Click" Content="Apply" Margin="5" HorizontalAlignment="Left" Width="80" Height="24" Grid.Row="1" 
                                                VerticalAlignment="Center"/>
                                    </Grid>
                                </GroupBox>
                                <GroupBox Header="Preferences" Margin="5">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition />
                                            <RowDefinition />
                                            <RowDefinition />
                                            <RowDefinition Height="35"/>
                                        </Grid.RowDefinitions>
                                        <StackPanel  Orientation="Horizontal" Margin="5" Grid.Row="0">
                                            <CheckBox Name="chkAutoStart" VerticalAlignment="Center"/>
                                            <TextBlock Text="Autostart with windows" VerticalAlignment="Center" Margin="5,0"/>
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal" Grid.Row="1">
                                            <TextBlock Text="Change wallpaper every " VerticalAlignment="Center"/>
                                            <TextBox Name="txtRefreshTime" Width="40" Height="23"></TextBox>
                                            <ComboBox Name="cboRefreshUnit" ItemsSource="{Binding}" IsEditable="False" Height="23" />
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal" Grid.Row="2">
                                            <TextBlock Text="Save Image to : " VerticalAlignment="Center"/>
                                            <TextBox Name="txtFolder" Width="330" Height="23"/>
                                            <Button  Width="30" Height="23"  Content="..." HorizontalAlignment="Left" Margin="0,3" Click="cmdBrowseFolder_Click"/>
                                        </StackPanel>
                                        <Button Click="ApplyPreferences_Click" Content="Apply" Margin="5" HorizontalAlignment="Left" Width="80" Height="24" Grid.Row="3"/>
                                    </Grid>
                                </GroupBox>
                                <GroupBox Margin="5">
                                    <GroupBox.Header>
                                        <StackPanel  Orientation="Horizontal">
                                            <CheckBox Content="AUTO UPDATE IMAGE" Name="chkAutoUpdate" Checked="chkAutoUpdate_Checked" Unchecked="chkAutoUpdate_Unchecked" Foreground="White"></CheckBox>
                                        </StackPanel>
                                    </GroupBox.Header>
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition />
                                            <RowDefinition Height="35"/>
                                        </Grid.RowDefinitions>
                                        <StackPanel  Orientation="Horizontal" Margin="5">
                                            <TextBlock Text="Download new images every " VerticalAlignment="Center" Name="lblAutoDownload"/>
                                            <TextBox Name="txtUpdateIntervall" Width="40" Height="23"/>
                                            <ComboBox Name="cboUpdateUnits" ItemsSource="{Binding}" IsEditable="False" Height="23"/>
                                        </StackPanel>
                                        <Button Click="ApplyAutoUpdate_Click" Content="Apply" Margin="5" HorizontalAlignment="Left" Width="80" Height="24" Grid.Row="1" 
                                                VerticalAlignment="Center"/>
                                    </Grid>
                                </GroupBox>
                                <GroupBox Margin="5">
                                    <GroupBox.Header>
                                        <CheckBox Content="{DynamicResource lbluseProxy}" x:Name="GboUseProxy" Click="useProxy_Click" Foreground="White"/>
                                    </GroupBox.Header>
                                    <Grid Margin="5">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                            <ColumnDefinition />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition/>
                                            <RowDefinition/>
                                            <RowDefinition/>
                                        </Grid.RowDefinitions>

                                        <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="0">
                                            <TextBlock Text="Address :" Width="50" />
                                            <TextBox  Grid.Column="1" x:Name="TxtIp" Height="23" Margin="5,0,0,0" Width="150"/>
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="0">
                                            <TextBlock Text="{DynamicResource lblIpPort}" Width="50" HorizontalAlignment="Right" />
                                            <TextBox  x:Name="TxtPort" Height="23" Margin="5,0,0,0" Width="150"/>
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="1">
                                            <TextBlock Text="{DynamicResource lblLogin}" Width="50" />
                                            <TextBox  Width="150" HorizontalAlignment="Left" x:Name="TxtLogin" Height="23" Margin="5,0,0,0"/>
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="1">
                                            <TextBlock Text="{DynamicResource lblPWD}" Width="50" />
                                            <TextBox Width="150" x:Name="TxtPwd" Height="23" Margin="5,0,0,0"/>
                                        </StackPanel>
                                        <Button Click="ApplyProxy_Click" Content="Apply" Margin="5" HorizontalAlignment="Left" Width="80" Height="24" Grid.Row="3" 
                                                VerticalAlignment="Center"/>

                                    </Grid>
                                </GroupBox>

                            </StackPanel>
                        </ScrollViewer>
                    </TabItem>
                    <TabItem Header="About">
                        <Grid Margin="5" Height="250" VerticalAlignment="Top" HorizontalAlignment="Center">
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>

                            <StackPanel Orientation="Horizontal" Grid.Row="0">
                                <TextBlock Text="YAWD"  FontSize="18" FontWeight="Bold" VerticalAlignment="Center"/>
                                <TextBlock Text="{DynamicResource Version}"  Name="lblVersion" VerticalAlignment="Center" Margin="5,0,0,0" FontSize="15"/>
                            </StackPanel>

                            <StackPanel Orientation="Horizontal" Grid.Row="1">
                                <TextBlock VerticalAlignment="Center" Text="{DynamicResource Contact}" FontSize="15"/>
                                <TextBlock VerticalAlignment="Center" Margin="5,0,0,0" FontSize="15">
                                    <Hyperlink Click="hypMail_Click" NavigateUri="mailto:myCollections.team@gmail.com">myCollections.team@gmail.com</Hyperlink>
                                </TextBlock>
                            </StackPanel>

                            <StackPanel Orientation="Horizontal" Grid.Row="2">
                                <TextBlock Text="Twitter :"  VerticalAlignment="Center" FontSize="15"/>
                                <TextBlock VerticalAlignment="Center" Margin="5,0,0,0" FontSize="15">
                                    <Hyperlink Click="hypMail_Click" NavigateUri="http://twitter.com/myCollections2">@myCollections2</Hyperlink>
                                </TextBlock>
                            </StackPanel>

                            <StackPanel Orientation="Horizontal" Grid.Row="3">
                                <TextBlock  Text="Google+ :" VerticalAlignment="Center" FontSize="15"/>
                                <TextBlock  VerticalAlignment="Center" Margin="5,0,0,0" FontSize="15">
                                     <Hyperlink Click="hypMail_Click" NavigateUri="http://plus.google.com/112855033947179134627/about">plus.google.com</Hyperlink>
                                </TextBlock>
                            </StackPanel>

                            <StackPanel Orientation="Horizontal" Grid.Row="4">
                                <TextBlock Text="{DynamicResource Home}" VerticalAlignment="Center" FontSize="15"/>
                                <TextBlock VerticalAlignment="Center" Margin="5,0,0,0" FontSize="15">
                                    <Hyperlink Click="hypMail_Click" NavigateUri="http://yawd.codeplex.com">yawd.codeplex.com</Hyperlink>
                                </TextBlock>
                            </StackPanel>

                            <TextBlock HorizontalAlignment="Center" Text="{DynamicResource Credits}" Grid.Row="5" FontWeight="Bold" FontSize="18"></TextBlock>

                            <StackPanel Orientation="Horizontal" Grid.Row="6">
                                <TextBlock Text="{DynamicResource TesterLead}" VerticalAlignment="Center" FontSize="15"/>
                                <TextBlock Text="Mariia Akcheurova" VerticalAlignment="Center" Margin="5,0,0,0" FontSize="15"/>
                            </StackPanel>

                            <StackPanel Orientation="Horizontal" Grid.Row="7">
                                <TextBlock Text="{DynamicResource WPFControls}" VerticalAlignment="Center" FontSize="15"/>
                                <TextBlock VerticalAlignment="Center" Margin="5,0,0,0" FontSize="15">
                                    <Hyperlink Click="hypMail_Click" NavigateUri="http://www.hardcodet.net/projects/wpf-notifyicon">hardcodet.net</Hyperlink>
                                </TextBlock>
                            </StackPanel>

                        </Grid>

                    </TabItem>
                </TabControl>
            </Grid>
        </controls:MetroContentControl>
    </Grid>
</controls:MetroWindow>
